<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script type="text/javascript">


        // 对象的创建方法
        // 1. var obj = {}  plainObject(朴素，普通)  对象字面量/对象直接量

        // 2. 构造函数
        //    1> 系统自带的构造函数  Object()
        //    2> 自定义 

        var obj = new Object(); //批量生产对象，每个对象相互独立

        obj.name = '小明';
        obj.say = function () {

        };


        function Car(color) { // 构造函数结构上和函数没有任何分别
            // 规范，构造函数严格符合大驼峰式命名规则，以防止后面维护困难，和普通函数混淆
            this.color = color;
            this.name = "BMW";
            this.height = "1400";
            this.lang = '4900';
            this.weight = 1000;
            this.health = 100;
            this.run = function() {
                this.health --;
            }
        }//里面书写一些共有的属性

        var car = new Car('red');
        var car1 = new Car('green');
        // car.color = 'red';
        // car1.color = 'green';
        console.log(car);
        console.log(car1);



        function Student(name, age, sex) {
            this.name = name;
            this.age = age;
            this.sex = sex;
            this.grade = 2017;
        }
        var student = new Student('小白', 26, '男');
    </script>
</body>

</html>